@import 'config';

/* BEM support Func
 -------------------------- */
@function selectorToString($selector) {
    $selector: inspect($selector);
    $selector: str-slice($selector, 2, -2);

    @return $selector;
}

@function containsModifier($selector) {
    $selector: selectortostring($selector);

    @if str-index($selector, $modifier-separator) {
        @return true;
    } @else {
        @return false;
    }
}

@function containWhenFlag($selector) {
    $selector: selectortostring($selector);

    @if str-index($selector, '.' + $state-prefix) {
        @return true;
    } @else {
        @return false;
    }
}

@function containPseudoClass($selector) {
    $selector: selectortostring($selector);

    @if str-index($selector, ':') {
        @return true;
    } @else {
        @return false;
    }
}

@function hitAllSpecialNestRule($selector) {
    @return containsModifier($selector) or containWhenFlag($selector) or
        containPseudoClass($selector);
}

@function rpx($px) {
    @return $px / 2;
}
